<?php

class sape extends Module {
	
	public function __construct () {
		parent::__construct(__CLASS__);		
	}
	
	public function __default() {
		throw new NotFound;
	}
	
	public function get ($code) {
		if (!defined('_SAPE_USER')){
			define('_SAPE_USER', $code); 
		} 

		$file = DOC_ROOT . '/' . _SAPE_USER . '/sape.php';
		
		if (!file_exists($file)) {
			$response = new ModuleResponse;
			$response->addObject('sape.php not found');

			return $response;
		}
		
		include $file; 

		$sape = new SAPE_client();

		$response = new ModuleResponse;
		$o['charset'] = 'UTF-8';
		
		$links = $sape->return_links($o);
		$links = str_replace('&', '&amp;', $links);
		
		$response->addObject($links);

		return $response;
	}
	
}